package sender

import (
	"cqrcsnmpserver/global"
	"fmt"
	log "github.com/sirupsen/logrus"
)

var senderFunc map[string]func(string, string)(error) = make(map[string]func(string, string)(error))

func init(){
			senderFunc["zabbix"] = SendToZabbix
			senderFunc["pushgateway"] = PushMetrics
}

func Sends(host string, msgheader string ) {
	for _, v := range global.GVA_CONFIG.Sender.Senders {
		if _, ok := senderFunc[v]; ok{
			if err := senderFunc[v](host, msgheader); err != nil {
				log.WithField("err", err).Error("send trap info error")
			}
		} else {
			log.Error(fmt.Sprintf("no such send method:[%s]",v))
		}
	}
}